<script>
	import { mapMutations } from 'vuex'
	export default {
		onLaunch: function() {
			/* 设置字体rem */
			// (function setRem() {
			// var width = document.body.offsetWidth; // 获取当前页面的宽度
			// var nowFont =10*(width/350); // 通过标签名称来获取元素 
			// var htmlFont = document.getElementsByTagName('html')[0]; // 给获取到的元素的字体大小赋值
			// htmlFont.style.fontSize = nowFont + "px";
			// })()
			console.log('App Launch')
			console.log('当uni-app初始化完成时触发应用初始化触发(全局只触发一次)')
			let userInfo = uni.getStorageSync('userInfo') || ''
			console.log('userInfo', userInfo)
			console.log('789', userInfo.userId)
			if (userInfo.userId) {
				this.login(userInfo)
				uni.switchTab({
					url: 'pages/tabbar/work/work'
				})
			} else {
				uni.navigateTo({
					url: 'pages/login/login'
				})
			}
			// 监听 midButton被点击了
			uni.onTabBarMidButtonTap(() => {
				uni.showToast({
					title: "midButton",
					duration: 1000
				})
			})
		},
		onShow: function() {
			console.log('App Show')
			console.log('当uni-app启动，或者后台进入前台显示')
		},
		onHide: function() {
			console.log('App Hide')
			console.log('当uni-app，从前端进入后台')
		},
		onLoad: function() {
			
		},
		methods: {
			...mapMutations(['login'])
		}
	}
</script>

<style lang="scss">
	/*每个页面公共css */
	@import './common/uni.css';
</style>
